package com.kpijavatraining.module2.menu;

import java.io.IOException;

import com.kpijavatraining.module.Training;
import com.kpijavatraining.module.User;
import com.kpijavatraining.module.io.ConsolePrinter;
import com.kpijavatraining.module.io.ConsoleReader;

public class UserMenu{

	private ConsoleReader consoleReader;
	private ConsolePrinter consolePrinter;
	
	public UserMenu(){
		consoleReader = new ConsoleReader();
		consolePrinter = new ConsolePrinter();
	}
		
	public void runMenu(User user) throws IOException, ClassNotFoundException, CloneNotSupportedException{
		loop:while(true){
			consolePrinter.println("1 - study");
			consolePrinter.println("2 - exit");
			switch(consoleReader.readLn()){
			case "1" : study(user);break;
			case "2" : break loop;
			}
		}
	}

	private void study(User user) throws ClassNotFoundException, IOException, CloneNotSupportedException{
		Training training = new Training();
		training.runStudy(user);
	}
}
